/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.4;
}

/* Responsive container - iframe vs full screen */
.app-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Full screen detection */
@media (min-height: 600px) {
    .app-container {
        height: 90vh;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Control Panel */
.control-panel {
    background: #fff;
    border-bottom: 2px solid #e1e8ed;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    min-height: 60px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Input and Select Styles */
.search-input, .location-select, .filter-select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    min-width: 120px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus, .location-select:focus, .filter-select:focus {
    outline: none;
    border-color: #007acc;
    box-shadow: 0 0 0 2px rgba(0,122,204,0.2);
}

/* Button Styles */
.btn {
    padding: 8px 16px;
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: #007acc;
    color: white;
    border-color: #007acc;
}

.btn-primary:hover {
    background: #005a99;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,122,204,0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-1px);
}

.btn-period, .btn-mode {
    background: #f8f9fa;
    color: #495057;
    border-color: #dee2e6;
}

.btn-period.active, .btn-mode.active {
    background: #007acc;
    color: white;
    border-color: #007acc;
}

.btn-period:hover, .btn-mode:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-period.active:hover, .btn-mode.active:hover {
    background: #005a99;
}

/* Period and Mode Controls */
.period-controls {
    border-left: 2px solid #e1e8ed;
    padding-left: 12px;
    margin-left: 8px;
}

.period-label, .mode-label {
    font-weight: 600;
    color: #495057;
    margin-right: 8px;
}

/* Selected Locations */
.selected-locations {
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 40px;
    align-items: center;
}

.location-tag {
    background: #007acc;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.location-tag:hover {
    background: #005a99;
    transform: scale(1.05);
}

.location-tag .remove-btn {
    background: rgba(255,255,255,0.3);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-tag .remove-btn:hover {
    background: rgba(255,255,255,0.5);
}

/* Graph Container */
.graph-container {
    flex: 1;
    padding: 16px;
    overflow: auto;
    background: white;
}

.graph-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    min-height: 300px;
}

/* Graph Styles */
.graph {
    width: 100%;
    height: 100%;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    background: white;
    position: relative;
    margin-bottom: 16px;
}

.graph-title {
    text-align: center;
    font-weight: 600;
    font-size: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
    cursor: pointer;
    transition: background-color 0.2s;
}

.graph-title:hover {
    background: #e9ecef;
}

.graph-svg {
    width: 100%;
    height: calc(100% - 60px);
    display: block;
}

/* Side-by-side layout */
.sidebyside-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: 100%;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s;
    max-width: 200px;
    text-align: center;
}

.tooltip.visible {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80%;
    overflow: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e1e8ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* Event Card Styles */
.event-info {
    margin-bottom: 16px;
}

.event-info h4 {
    color: #007acc;
    margin-bottom: 8px;
}

.event-detail {
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
}

.event-detail strong {
    min-width: 80px;
    color: #495057;
}

.focus-months-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 12px;
    transition: background-color 0.2s;
}

.focus-months-btn:hover {
    background: #218838;
}

/* Responsive Design */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
    }
    
    .control-group {
        justify-content: center;
    }
    
    .period-controls {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        border-top: 1px solid #e1e8ed;
        padding-top: 8px;
    }
    
    .sidebyside-container {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .btn {
        min-width: 100px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .app-container {
        border: 3px solid #000;
    }
    
    .btn {
        border-width: 3px;
    }
    
    .graph {
        border-width: 2px;
        border-color: #000;
    }
}

/* Focus styles for accessibility */
.btn:focus, .search-input:focus, .location-select:focus, .filter-select:focus {
    outline: 3px solid #007acc;
    outline-offset: 2px;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    font-style: italic;
}

/* No data state */
.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #999;
    font-style: italic;
    flex-direction: column;
    gap: 8px;
}

.no-data-icon {
    font-size: 48px;
    opacity: 0.5;
}